home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
clang
/
ndp.zip
/
NDP_TYPE.ASM
next >
Wrap
Assembly Source File
|
1987-08-01
|
4KB
|
98 lines
page 60,132
title ndp_type() - Math Coprocessor Check
; ndp_type - Check for Math Coprocessor -
; Report Presence and Type....
;
; calling convention:
;
; int ndp_type( void );
;
; returns:
;
; you get back 0 if NO CHIP is found
; 1 if an 8087 is found
; 2 if an 80287
; and 3 for an 80387
;
;
; FREELY adopted from Ted Forgeron's
; article and code in PC Tech
; Journal, Aug 87 p 43 /Psi!
_text SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:_text
PUBLIC _ndp_type
_ndp_type PROC NEAR
control dw 0
push BP ; save where Ur at when
mov BP,SP ; going in.....
push DI
push SI
push CX ; not really needed for
; MSC but nice to do
; Check for an NDP. Don't forget to assemble with the /R option
; set in MASM or you'll bomb cuz of the coprocessor instructions.
do_we: fninit ; try to initialize NDP
mov byte ptr control+1,0 ; clear memory byte
fnstcw control ; put control word in mem
mov AH,byte ptr control+1 ; iff AH is 03h, you got
cmp AH,03h ; an NDP on board !!
je chk_87 ; found somethin', keep goin'
xor AX,AX ; clean out AX to show a zero
jmp short byebye ; return [no NDP]
; 'got an 8087 ??
chk_87: and control,NOT 0080h ; turn ON interrupts (IEM=0)
fldcw control ; load control word
fdisi ; turn OFF interrupts (IEM=1)
fstcw control ; store control word
test control,0080h ; iff IEM=1, 8087
jz chk287 ; 'guess not! March on....
mov AX,0001 ; set up for a 1 return to
jmp short byebye ; show an 8087
; if not.... would you believe an 80287 maybe ??
chk287: finit ; set default infinity mode
fld1 ; make infinity
fldz ; by dividing
fdiv ; 1 by zero !!
fld st ; now make a
fchs ; negative infinity
fcompp ; compare Ur two infinities
fstsw control ; iff, for 8087 or 80287
fwait ; 'til status word is put away
mov AX,control ; getchur control word
sahf ; putchur AH into flags
jnz got387 ; NO GOOD.... march on !!
mov AX,0002 ; gotta be a 80287 cuz we al-
jmp short byebye ; ready tested for an 8087
; We KNOW that there is an NDP on board otherwise we would have bailed
; out after 'do_we'. It isn't an 8087 or an 80287 or we wouldn't have
; gotten this far. It's gotta be an 80387 !!
got387: mov AX,0003 ; it isn't an 8087 or an 80287
; but we do know it is an NDP
; so let's call it an 80387
; and return a 3
byebye: pop CX ; put things back the way that
pop SI ; you found 'em
pop DI
pop BP
ret ; and go back where you came
; from
_ndp_type endp
_text ends
end